﻿using System.Threading;

namespace Z2.Core
{
    public delegate void ParallelActionInvoker();

    public class ParallelOperation
    {
        private readonly ParallelActionInvoker m_invoker;

        public ParallelOperation(ParallelActionInvoker invoker)
        {
            this.m_invoker = invoker;
            this.DoneEvent = new ManualResetEvent(false);
        }

        public ManualResetEvent DoneEvent { get; private set; }

        public void ThreadPoolCallback(object threadContext)
        {
            this.m_invoker.Invoke();
            this.DoneEvent.Set();
        }
    }
}
